#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include <stdlib.h>

typedef struct 
{
	int val;
	char str[256];
}para;

void *tfn(void *arg)
{
	printf("enter tfn \n");
	para *temp = (para*)arg;
	return (void*)temp;
}

int main(int argc, char**argv)
{
	para *arg;
	para *ret;

	arg = (para*)malloc(sizeof(para));
	arg->val = atoi(argv[1]);
	strcpy(arg->str, argv[2]);
		
	pthread_t thread;

	pthread_create(&thread, NULL, tfn, (void *)arg);

	pthread_join(thread, (void**)&ret);

	printf("val: %d str: %s\n", ret->val, ret->str);

	free(arg);//arg and ret is pointed to the same address. 

	pthread_exit(NULL);
}
